package com.mit.wx.util;

import com.mit.wx.wx.dto.SourceMessage;
import com.mit.wx.wx.dto.XmlConvertible;
import com.thoughtworks.xstream.XStream;

/**
 * @author 郭文梁
 * <p>Create by 郭文梁</p>
 * <p>FOR:微信XML工具 </p>
 */
public class WxXmlUtil {
    private static final XStream X_STREAM = new XStream();

    static {
        X_STREAM.processAnnotations(SourceMessage.class);
        X_STREAM.autodetectAnnotations(true);
    }

    public static SourceMessage parseMessageXML(String xml) {
        return (SourceMessage) X_STREAM.fromXML(xml);
    }

    public static String toXML(XmlConvertible obj) {
        return X_STREAM.toXML(obj);
    }
}
